home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / sbhc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.0 KB  |  94 lines

  1. /* Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: sbhc.h,v 1.2 2000/09/19 19:00:47 lpd Exp $ */
  20. /* Definitions for BoundedHuffman filters */
  21. /* Requires strimpl.h */
  22.  
  23. #ifndef sbhc_INCLUDED
  24. #  define sbhc_INCLUDED
  25.  
  26. #include "shc.h"
  27.  
  28. /*
  29.  * The BoundedHuffman filters extend the basic Huffman coding model by
  30.  * providing the ability to encode runs of zeros as a single data item,
  31.  * and by providing an end-of-data (EOD) marker.
  32.  */
  33. #define max_zero_run 100
  34.  
  35. /* Common state */
  36. #define stream_BHC_state_common\
  37.     stream_hc_state_common;\
  38.     hc_definition definition;\
  39.         /* The client sets the following before initialization. */\
  40.     bool EndOfData;\
  41.     uint EncodeZeroRuns;\
  42.         /* The following are updated dynamically. */\
  43.     int zeros        /* # of zeros scanned or left to output */
  44. typedef struct stream_BHC_state_s {
  45.     stream_BHC_state_common;
  46. } stream_BHC_state;
  47.  
  48. /* BoundedHuffmanEncode */
  49. typedef struct stream_BHCE_state_s {
  50.     stream_BHC_state_common;
  51.     hce_table encode;
  52. } stream_BHCE_state;
  53.  
  54. #define private_st_BHCE_state()    /* in sbhc.c */\
  55.   gs_private_st_ptrs3(st_BHCE_state, stream_BHCE_state,\
  56.     "BoundedHuffmanEncode state", bhce_enum_ptrs, bhce_reloc_ptrs,\
  57.     definition.counts, definition.values, encode.codes)
  58. extern const stream_template s_BHCE_template;
  59.  
  60. #define s_bhce_init_inline(ss)\
  61.   (s_hce_init_inline(ss), (ss)->zeros = 0)
  62.  
  63. /* BoundedHuffmanDecode */
  64. typedef struct stream_BHCD_state_s {
  65.     stream_BHC_state_common;
  66.     hcd_table decode;
  67. } stream_BHCD_state;
  68.  
  69. #define private_st_BHCD_state()    /* in sbhc.c */\
  70.   gs_private_st_ptrs3(st_BHCD_state, stream_BHCD_state,\
  71.     "BoundedHuffmanDecode state", bhcd_enum_ptrs, bhcd_reloc_ptrs,\
  72.     definition.counts, definition.values, decode.codes)
  73. extern const stream_template s_BHCD_template;
  74.  
  75. #define s_bhcd_init_inline(ss)\
  76.   (s_hcd_init_inline(ss), (ss)->zeros = 0)
  77.  
  78. /* Declare variables that hold the decoder state. */
  79. #define bhcd_declare_state\
  80.     hcd_declare_state;\
  81.     int zeros
  82.  
  83. /* Load the state from the stream. */
  84. /* Free variables: pr, ss, p, rlimit, bits, bits_left, zeros. */
  85. #define bhcd_load_state()\
  86.     hcd_load_state(), zeros = ss->zeros
  87.  
  88. /* Store the state back in the stream. */
  89. /* Free variables: pr, ss, p, bits, bits_left, zeros. */
  90. #define bhcd_store_state()\
  91.     hcd_store_state(), ss->zeros = zeros
  92.  
  93. #endif /* sbhc_INCLUDED */
  94.